package com.atguigu.day23.work;

import org.junit.Test;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintStream;
import java.util.Scanner;

public class Work7 {
    @Test
    public void w1() throws FileNotFoundException {
        Scanner input =new Scanner(System.in);
        PrintStream ps=new PrintStream("words.txt");
        for (int i = 0; i < 3; i++) {
             System.out.println("请输入第"+(i+1)+"句话: ");
             String content=input.nextLine();
             ps.println(content);
        }
        input.close();
        ps.close();
    }
    @Test
    public void w2() throws FileNotFoundException {
        Scanner input=new Scanner((new File("words.txt")));
        while (input.hasNextLine()){
            System.out.println(input.nextLine());
        }
        input.close();
    }
}
